const houUrl = window.toH5Url;
// const houUrl = 'https://b2api-test.sqqmall.com';

const tbUnionurl = function(tm, couponAmount, picUrl, skuId, skuName, wlPriceAfter, endTime, startTime, h5Url, appUrl) {
	try {
		const url = window.toH5Url;
		uni.request({
			url: url + '/coupon-customer/rechargeable/consume/deduction',
			method: 'POST',
			async: true,
			header: {
				'blade-auth': decodeURI(uni.getStorageSync('token')) || decodeURI(UrlParam().token),
				'content-type': 'application/json'
			},
			data: {
				deduction: tm == 'true' ? 4 : 3, //平台id
				deductionAmount: couponAmount,
				picUrl: picUrl,
				skuId: skuId,
				skuName: skuName,
				wlPrice: 0,
				wlPriceAfter: wlPriceAfter,
				endTime: endTime,
				startTime: startTime,
				htmlQuanUrl: encodeURIComponent(h5Url),
				appQuanUrl: encodeURIComponent(appUrl)
			},
			success: res => {
				let datas = res.data;
				if (datas.code == 200) {
					uni.showToast({
						icon: 'none',
						title: '领取成功'
					});
					callNative('onStartApp', {
						urlH5: h5Url,
						urlApp: appUrl
					}, '', () => {
						appNavigateTo(h5Url);
					});
				} else if (datas.code == 401) {
					// this.valida();
					onStartLogin();
				} else {
					uni.showToast({
						icon: 'none',
						title: datas.msg
					});
				}
			}
		});
	} catch (e) {
		console.log('get tb relationid fail===' + e)
	}

}

export default {
	tbUnionurl,
	houUrl
}
